/**
 * @param {number} n
 * @return {number}
 */
export var subtractProductAndSum = function (n) {
  let sum = 0
  let product = 1
  while (n) {
    const rmd = n % 10
    sum += rmd
    product *= rmd
    n = Math.floor(n / 10)
  }
  return product - sum
}
